[QUIZ] Test your understanding of SQL - Part 6

In order to serve your work and your study, along with SQL lessons, Quantrimang offers a variety of useful questions.

  1. Question 1: Which SQL statement would you use to select all columns from the THONGTIN_SACH table below?
    THONGTIN_SACH Table:
    Ten_cot ID_SACH TEN_SACH GIA
    * Table used for questions from 1 to 10.
    1. SELECT ID_SACH + GIA FROM THONGTIN_SACH;
    2. SELECT * FROM THONGTIN_SACH;
    3. SELECT ALL FROM THONGTIN_SACH;
    4. SELECT ALL COLUMNS FROM THONGTIN_SACH;

  2. Question 2: Which SQL statement is used to select all books with prices higher than 200000?
    1. SELECT ID_SACH FROM THONGTIN_SACH HAVING GIA> 200000;
    2. SELECT ID_SACH FROM THONGTIN_SACH ONLY GIA> 200000;
    3. SELECT ID_SACH FROM THONGTIN_SACH WHERE ID_SACH> 200000;
    4. SELECT ID_SACH FROM THONGTIN_SACH WHERE GIA> 200000;
  3. Question 3: Which SQL statement is used to select all books whose title starts with 'A'?
    1. SELECT ID_SACH, TEN_SACH FROM THONGTIN_SACH WHERE TEN_SACH LIKE 'A';
    2. SELECT ID_SACH, TEN_SACH FROM THONGTIN_SACH WHERE TEN_SACH IN 'A';
    3. SELECT ID_SACH, TEN_SACH FROM THONGTIN_SACH WHERE TEN_SACH LIKE 'A%';
    4. SELECT ID_SACH, TEN_SACH FROM THONGTIN_SACH WHERE TEN_SACH LIKE '% A';
  4. Question 4: Which SQL statements allow sorting all books by high to low prices?
    1. SELECT ID_SACH, TEN_SACH, GIA FROM THONGTIN_SACH ORDER BY GIA DESC;
    2. SELECT ID_SACH, TEN_SACH, GIA FROM THONGTIN_SACH SORT BY GIA DESC;
    3. SELECT ID_SACH, TEN_SACH, GIA FROM THONGTIN_SACH SORT BY GIA ASC;
    4. SELECT ID_SACH, TEN_SACH, GIA FROM THONGTIN_SACH ORDER BY GIA ASC;
  5. Question 5: Which SQL statement allows inserting the following data segment into THONGTIN_SACH?
     ID_SACH = 20 
    TEN_SACH = 'HOC SQL TU QUANTRIMANG.COM'
    GIA = 150000
    1. ADD INTO THONGTIN_SACH WITH (20, 'HOC SQL TU QUANTRIMANG.COM', 150000);
    2. INSERT INTO THONGTIN_SACH USING (20, 'HOC SQL TU QUANTRIMANG.COM', 150000);
    3. INSERT INTO THONGTIN_SACH VALUES (20, 'HOC SQL TU QUANTRIMANG.COM', 150000);
    4. ADD INTO THINKSNESS VALUES (20, 'HOC SQL TU QUANTRIMANG.COM', 150000);
  6. Question 6: Which SQL statement allows to delete the THONGTIN_SACH table from the database?
    1. DROP THONGTIN_SACH;
    2. DELETE TABLE THONGTIN_SACH;
    3. TRUNCATE TABLE THONGTIN_SACH;
    4. DROP TABLE THONGTIN_SACH;
  7. Question 7: Which SQL statement is used to delete rows with ID_SACH = 15?
    1. TRUNCATE TABLE THONGTIN_SACH WHERE ID_SACH = 15;
    2. DELETE FROM THONGTIN_SACH WHERE ID_SACH = 15;
    3. DROP THONGTIN_SACH WHERE ID_SACH = 15;
    4. TRUNCATE THONGTIN_SACH WHERE ID_SACH = 15;
  8. Question 8: Which SQL statement used to change prices for SACH titled 'HOC SQL TU QUANTRIMANG.COM' to 200000?
    1. UPDATE THONGTIN_SACH SET GIA = 200000 WHERE TEN_SACH = 'HOC SQL TU QUANTRIMANG.COM';
    2. UPDATE TABLE THONGTIN_SACH SET GIA = 200000 WHERE TEN_SACH = 'HOC SQL TU QUANTRIMANG.COM';
    3. UPDATE THONGTIN_SACH CHANGE GIA = 200000 WHERE TEN_SACH = 'HOC SQL TU QUANTRIMANG.COM';
    4. UPDATE TABLE THONGTIN_SACH SET GIA = 200000 WHERE ID_SACH = 'HOC SQL TU QUANTRIMANG.COM';
  9. Question 9: Which SQL statement allows to find the highest price from the table THONGTIN_SACH?
    1. SELECT ID_SACH, TEN_SACH, MAX (GIA) FROM THONGTIN_SACH;
    2. SELECT MAX (GIA) FROM THONGTIN_SACH;
    3. SELECT MAXIMUM (GIA) FROM THONGTIN_SACH;
    4. SELECT GIA FROM THONGTIN_SACH ORDER BY GIA DESC;
  10. Question 10: Which SQL statement allows to find all books priced from 150000 to 200000?
    1. SELECT ID_SACH, TEN_SACH, GIA FROM THONGTIN_SACH WHERE GIA IS BETWEEN 150000 AND 200000;
    2. SELECT ID_SACH, TEN_SACH, GIA FROM THONGTIN_SACH HAVING GIA IS BETWEEN 150000 AND 200000;
    3. SELECT ID_SACH, TEN_SACH, GIA FROM THONGTIN_SACH WHEN GIA BETWEEN 150000 AND 200000;
    4. SELECT ID_SACH, TEN_SACH, GIA FROM THONGTIN_SACH HAVING GIA BETWEEN 150000 AND 200000;
  11. Question 11: Following the table below, which SQL statement will find the sales amount of each store?
    Table BANHANG:
    Ten_cot ID_CUAHANG NGAY_BAN BUSINESS_THU
    * Table used for questions 11 to 15.
    1. SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG;
    2. SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG ORDER BY ID_CUAHANG;
    3. SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG GROUP BY ID_CUAHANG;
    4. SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG HAVING UNIQUE ID_CUAHANG;
  12. Question 12: Which SQL statement allows you to list all stores with total sales over 5000?
    1. SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG GROUP BY ID_CUAHANG HAVING SUM (JOINT_THU)> 5000;
    2. SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG GROUP BY ID_CUAHANG HAVING JOINT_THU> 5000;
    3. SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG WHERE SUM (BUSINESS_THU)> 5000 GROUP BY ID_CUAHANG;
    4. SELECT ID_CUAHANG, SUM (BUSINESS_THU) FROM BANHANG WHERE JOINT_THU> 5000 GROUP BY ID_CUAHANG;
  13. Question 13: Which SQL statement is used to find the earliest date that store ID = 10 has revenue greater than 0?
    1. SELECT MAX (NGAY_BAN) FROM BANHANG WHERE ID_CUAHANG = 10 AND JOINT_THU> 0;
    2. SELECT NGAY_BAN FROM BANHANG WHERE ID_CUAHANG = 10 AND JOINT_THU> 0;
    3. SELECT MIN (NGAY_BAN) FROM BANHANG WHERE ID_CUAHANG = 10 OR JOINT_THU> 0;
    4. SELECT MIN (NGAY_BAN) FROM BANHANG WHERE ID_CUAHANG = 10 AND JOINT_THU> 0;
  14. Question 14: Which SQL statement allows to find the total number of stores in the BANHANG table?
    1. SELECT COUNT (ID_CUAHANG) FROM BANHANG;
    2. SELECT COUNT (DISTINCT ID_CUAHANG) FROM BANHANG;
    3. SELECT DISTINCT ID_CUAHANG FROM BANHANG;
    4. SELECT COUNT (ID_CUAHANG) FROM BANHANG GROUP BY ID_CUAHANG;
    See also DISTINCT Keywords in SQL
  15. Question 15: Which SQL statement allows you to find the total number of store sales with ID is 25 and the store has an ID of 45?
    1. SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG WHERE ID_CUAHANG IN (25.45) GROUP BY ID_CUAHANG;
    2. b) SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG GROUP BY ID_CUAHANG HAVING ID_CUAHANG IN (25.45);
    3. c) SELECT ID_CUAHANG, SUM (Doanh_THU) FROM BANHANG WHERE ID_CUAHANG IN (25.45);
    4. d) SELECT ID_CUAHANG, SUM (BUSINESS_THU) FROM BANHANG WHERE ID_CUAHANG = 25 AND ID_CUAHANG = 45 GROUP BY ID_CUAHANG;
Update 24 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile